//
//  ZYCGrowthFileParentViewController.m
//  ZDSC
//
//  Created by ZDTX on 2021/9/19.
//

#import "ZYCGrowthFileParentViewController.h"
#import "ZYCGrowthFileModel.h"
#import "ZYCGrowthFileParentSelectView.h"
#import "ZYCCircleFriendsViewController.h"

@interface ZYCGrowthFileParentViewController ()

@property (nonatomic, strong)ZYCGrowthFileParentSelectView *electiveStudentView;
@end

@implementation ZYCGrowthFileParentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"选择学生";
    
    [self.view addSubview:self.electiveStudentView];
    [self queryStuListByParent];
}

- (ZYCGrowthFileParentSelectView *)electiveStudentView {
    ZYCWeakSelf
    if (!_electiveStudentView) {
        _electiveStudentView = [[ZYCGrowthFileParentSelectView alloc] initWithFrame:CGRectMake(0, kNavBarAndStatusBarHeight, kScreenWidth, kScreenHeight - kNavBarAndStatusBarHeight)];
        _electiveStudentView.selectStuBlock = ^(ZYCGrowthFileModel * _Nonnull model) {
            ZYCCircleFriendsViewController *vc = [[ZYCCircleFriendsViewController alloc] init];
            vc.model = model;
            vc.titleString = model.name;
            [weakSelf.navigationController pushViewController:vc animated:YES];
        };
    }
    return _electiveStudentView;
}


- (void)queryStuListByParent{
    [[URLManager sharedURLManager] postUrlString:Appliance_Post_StuListByParent requestService:RequestServiceWorkBench parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
            
        } success:^(id  _Nullable responseObject) {
            if (SUCCESS(responseObject[@"code"])) {
                NSArray *array = [NSArray yy_modelArrayWithClass:[ZYCGrowthFileModel class] json:responseObject[@"body"]];
                self.electiveStudentView.dataSource = array;
                [self.electiveStudentView reload];
                
            }
        } failure:^(NSError * _Nonnull error) {
            
        }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
